package com.fang.gateway.security.entity.bo;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @Description
 * @Author Bernie_fang
 * @Date 2025/3/9 13:47
 **/
@Data
public class SecurityUserDetailsBo implements UserDetails {

    private Integer id;
    /**
     * 账号ID
     */
    private String userId;
    /**
     * 角色标识
     */
    private String identifier;
    /**
     * 账号
     */
    private String username;

    /**
     * 用户密码
     */
    private String password;

    /**
     * 账号是否可用。默认为1（可用）
     */
    private Boolean enabled;

    /**
     * 是否过期。默认为0（没有过期）
     */
    private Boolean notExpired;

    /**
     * 账号是否锁定。默认为0（没有锁定）
     */
    private Boolean accountNotLocked;

    /**
     * 证书（密码）是否过期。默认为0（没有过期）
     */
    private Boolean credentialsNotExpired;

    private ArrayList<WebFluxAuthoritiesBo> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return notExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNotLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNotExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

}
